// store/store.go
package store

import (
	"fmt"
	"gin-epg/internal/app/common/util"
	"gin-epg/internal/app/dao"
)

var GlobalStoreService StoreService

//var StoreService service.StoreService

func InitStoreService() error {
	fileStorageType, err := util.GetConfigValue("fileStorage.type")
	if err != nil {
		return err
	}

	switch fileStorageType {
	case "oss":
		err := dao.InitOSS()
		if err != nil {
			return err
		}
		var initErr error
		GlobalStoreService, initErr = NewOSSStoreService()
		if initErr != nil {
			return initErr
		}
	case "local":
		err := dao.InitLocal()
		if err != nil {
			return err
		}
		var initErr error
		GlobalStoreService, initErr = NewLocalStoreService()
		if initErr != nil {
			return initErr
		}
	default:
		return fmt.Errorf("未知的存储类型")
	}

	return nil
}
